"""
Web
"""

import streamlit as st
from src.core.ollama_client import RECOMMENDED_MODELS

class Sidebar:
    """"""
    
    @staticmethod
    def render():
        """"""
        st.sidebar.header(" ")
        
        # Whisper
        model_options = {
            'tiny': 'Tiny (39MB) - ',
            'base': 'Base (74MB) - ',
            'small': 'Small (244MB) - ',
            'medium': 'Medium (769MB) - ',
            'large': 'Large (1550MB) - '
        }
        
        selected_model = st.sidebar.selectbox(
            " Whisper",
            options=list(model_options.keys()),
            index=list(model_options.keys()).index(st.session_state.settings['whisper_model']),
            format_func=lambda x: model_options[x],
            help=""
        )
        st.session_state.settings['whisper_model'] = selected_model
        
        # Ollama
        ollama_options = {
            'qwen2:1.5b': 'Qwen2 1.5B - ',
            'qwen2:7b': 'Qwen2 7B - ',
            'llama3.1:8b': 'Llama3.1 8B - ',
            'llama3.2:3b': 'Llama3.2 3B - '
        }
        
        selected_ollama = st.sidebar.selectbox(
            " Ollama",
            options=list(ollama_options.keys()),
            index=list(ollama_options.keys()).index(st.session_state.settings['ollama_model']) if st.session_state.settings['ollama_model'] in ollama_options else 0,
            format_func=lambda x: ollama_options[x],
            help="AI"
        )
        st.session_state.settings['ollama_model'] = selected_ollama
        
        # 
        language_options = {
            'auto': ' ',
            'zh': ' ',
            'en': ' ',
            'ja': ' ',
            'ko': ' ',
            'fr': ' ',
            'de': ' ',
            'es': ' ',
            'ru': ' '
        }
        
        selected_language = st.sidebar.selectbox(
            " ",
            options=list(language_options.keys()),
            index=list(language_options.keys()).index(st.session_state.settings['language']),
            format_func=lambda x: language_options[x],
            help=""
        )
        st.session_state.settings['language'] = selected_language
        
        # 
        style_options = {
            'concise': ' ',
            'detailed': ' ',
            'bullet_points': ' ',
            'academic': ' ',
            'business': ' ',
            'educational': ' '
        }
        
        selected_style = st.sidebar.selectbox(
            " ",
            options=list(style_options.keys()),
            index=list(style_options.keys()).index(st.session_state.settings['summary_style']),
            format_func=lambda x: style_options[x],
            help=""
        )
        st.session_state.settings['summary_style'] = selected_style
        
        # 
        format_options = {
            'txt': '  (.txt)',
            'srt': ' SRT (.srt)',
            'vtt': ' WebVTT (.vtt)',
            'json': ' JSON (.json)',
            'md': ' Markdown (.md)',
            'html': ' HTML (.html)'
        }
        
        selected_formats = st.sidebar.multiselect(
            " ",
            options=list(format_options.keys()),
            default=st.session_state.settings['output_formats'],
            format_func=lambda x: format_options[x],
            help=""
        )
        st.session_state.settings['output_formats'] = selected_formats
        
        # 
        with st.sidebar.expander(" "):
            chunk_duration = st.slider(
                "",
                min_value=300,
                max_value=1800,
                value=600,
                step=300,
                help=""
            )
            st.session_state.settings['chunk_duration'] = chunk_duration
            
            device = st.selectbox(
                "",
                options=['auto', 'cpu', 'cuda'],
                help="auto"
            )
            st.session_state.settings['device'] = device
            
            cleanup_temp = st.checkbox(
                "",
                value=True,
                help=""
            )
            st.session_state.settings['cleanup_temp'] = cleanup_temp
        
        return st.session_state.settings